package smtp;

import java.util.Properties;

import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;

public class UserSession {


	private				String user="";
	private 			String password="";
	Properties			props=null;
	
	public UserSession(String host,int port){
	    props= new Properties();
		props.put("mail.smtp.host", host);
    	props.put("mail.smtp.port", port);
		props.put("mail.smtp.auth", "true");
	}
	
	public Session getSession(){
		return Session.getDefaultInstance(props, new EmailAuthenticator());
	}

	private class EmailAuthenticator extends Authenticator{

		protected PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication(user, password);
        }
	}
	

}
